package org.NooLab.docserver.component;

import java.io.Serializable;
import java.util.ArrayList;

import org.NooLab.docserver.main.DocumentObserverFileCore;




public class WatchedFile implements Serializable{

	private static final long serialVersionUID = 4752797130735455741L;
	
	protected WatchedFile wFinstance ;
	
	String  filename="";
	String  homeDir="";
	
	long    LDate;
	long    filesize = -1;
	boolean changed ;
	int     removeThis ;
	
	String  observation="" ;    // MOD, NEW, DEL
	int     internalFlag = -1;  // 3    2    -3
	String  previousLabel = "";

	private long folderId;
	
	
	// ------------------------------------------------------------------------
	public 	WatchedFile(){
		wFinstance  =this;
	}
	
	public WatchedFile(WatchedFile inWF) {

		filename = inWF.filename   ; 
		homeDir  = inWF.homeDir  ;
		LDate    = inWF.LDate  ;
		filesize = inWF.filesize  ;
		changed  = inWF.changed  ;
		removeThis   = inWF.removeThis  ;
		observation  = inWF.observation  ;
		internalFlag = inWF.internalFlag  ;
		folderId     = inWF.folderId ;
		previousLabel = inWF.previousLabel ;
		
		wFinstance  =this;
	}

	// ------------------------------------------------------------------------	

	public WatchedFile getwFinstance() {
		return wFinstance;
	}

	public boolean isEqual(WatchedFile inWF) {
		boolean rB = false;
		
		if (inWF==null){
			return false;
		}
		
		if ( 		
				(filename.contentEquals(inWF.filename )) &&  
				(homeDir.contentEquals(inWF.homeDir )) && 
				(LDate    == inWF.LDate ) && 
				(filesize == inWF.filesize ) && 
				(changed  == inWF.changed ) && 
				(removeThis   == inWF.removeThis ) && 
				(observation  == inWF.observation ) && 
				(internalFlag == inWF.internalFlag ) && 
				(folderId     == inWF.folderId ) && 
				(previousLabel == inWF.previousLabel )){
			rB=true;
		}
		
		
		return rB;
	}

	
	public int findItem(ArrayList<WatchedFile> items) {
		int p=-1;
		
		for (int i=0;i<items.size();i++){
			
			if (isEqual(items.get(i))){
				p=i;
				break;
			}
		}// i->
		
		return p;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public long getLDate() {
		return LDate;
	}

	public void setLDate(long lDate) {
		LDate = lDate;
	}

	public long getFilesize() {
		return filesize;
	}

	public void setFilesize(long filesize) {
		this.filesize = filesize;
	}

	public boolean isChanged() {
		return changed;
	}

	public void setChanged(boolean changed) {
		this.changed = changed;
	}

	public int getRemoveThis() {
		return removeThis;
	}

	public void setRemoveThis(int removeThis) {
		this.removeThis = removeThis;
	}

	public String getObservation() {
		return observation;
	}

	public void setObservation(String observation) {
		this.observation = observation;
	}

	public int getInternalFlag() {
		return internalFlag;
	}

	public void setInternalFlag(int internalFlag) {
		this.internalFlag = internalFlag;
	}

	public String getHomeDir() {
		return homeDir;
	}

	public void setHomeDir(String homeDir) {
		this.homeDir = homeDir;
	}

	public String getPreviousLabel() {
		return previousLabel;
	}

	public void setPreviousLabel(String previousLabel) {
		this.previousLabel = previousLabel;
	}

	public void setFolderId(long folderid) {
		
		this.folderId = folderid;
	}

	public long getFolderId() {
		return folderId;
	}

	
	
	
	
}
